<template>
    <div>
        <van-nav-bar title="新增地址" fixed>
            <div class="left_arrow" @click="()=>{ $router.go(-1) }" slot="left">
                <van-icon name="arrow-left"/>
                <span>返回</span>
            </div>
        </van-nav-bar>
        <div class="top"></div>
        <!-- 地址表单 -->
        <van-address-edit
            :area-list="areaList"
            show-postal
            show-delete
            show-set-default
            show-search-result
            :search-result="searchResult"
            :area-columns-placeholder="['请选择', '请选择', '请选择']"
            @save="onSave"
            @delete="onDelete"
            @change-detail="onChangeDetail"
        />
    </div>
</template>

<script>
import areaList from "../../assets/area.js";

export default {
  data() {
    return {
      areaList,
      searchResult: []
    };
  },
  methods: {
    onSave(content) {
    // Toast("save");
    this.$store.commit('addAddress',content)
    this.$router.push('address_list')
    },
    onDelete() {
    //   Toast("delete");
    },
    onChangeDetail(val) {
    //   if (val) {
    //     this.searchResult = [
    //       {
    //         name: "黄龙万科中心",
    //         address: "杭州市西湖区"
    //       }
    //     ];
    //   } else {
    //     this.searchResult = [];
    //   }
    }
  }
};
</script>

<style lang="less" scoped>
.top {
    height: 46px;
}
</style>